import request from '@/utils/request'

// 注册
export function register(data) {
  return request({
    url: '/register',
    method: 'post',
    data
  })
}

// 登录
export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data
  })
}

// 获取公钥
export function getPublicKey() {
  return request({
    url: '/getPublicKey',
    method: 'get'
  })
}

// 获取用户信息
export function getUserInfo() {
  return request({
    url: '/userinfo',
    method: 'get'
  })
}

// 获取作者信息
export function getAuthorInfo(id) {
  return request({
    url: '/authorinfo/' + id,
    method: 'get'
  })
}

// 修改密码
export function changePwd(data) {
  return request({
    url: '/changePwd',
    method: 'post',
    data
  })
}

// 修改作者信息
export function updateAuthorInfo(data) {
  return request({
    url: '/updateAuthorInfo',
    method: 'post',
    data
  })
}

// 头像上传
export function uploadAvatar(params) {
  var formData = params
  return request({
    url: '/upload/avatar',
    method: 'post',
    'Content-Type': 'multipart/form-data',
    data: formData
  })
}
